#!/bin/bash

# It appears that this file is NOT installed by OMakefile. If installing it in
# the future, make sure that variable BASE_PATH is set correctly.

if [ -z $1 ]
then
  echo "Need to specify the current network interface (e.g. eth0) as a parameter
 to this script"
  exit 1
fi  

IF=$1

export PATH=$PATH:@BINDIR@

# generic stuff, necessary for xenrt too

#install necessary packages
yum -y install nc
yum -y install rsync
yum -y install wget

# mount the iso directory
mount bespin:/scratch/images/autoinstall /var/opt/xen/iso_import

# make a lv for import/export tests, mount it on /mnt
VG=`vgs --noheadings -o size,name,size --separator=, | cut -d, -f2`
lvcreate -n importexport -L 10G $VG
mke2fs /dev/$VG/importexport
mount /dev/$VG/importexport /mnt

#tmp dir for logging output
mkdir -p /tmp/rt
cd /tmp/rt
wget http://snoosnoo.uk.xensource.com/~jludlam/test.css
wget http://snoosnoo.uk.xensource.com/~jludlam/test_log.js

# post this line is non-xenrt only. xenrt should provide the vms
# rather than having to import them.

# mount the volume with the images on
mkdir -p /tmp/vms
mount bespin:/scratch2/jludlam /tmp/vms

# import them

cd /tmp/vms/
./debian.sh $IF
./debian-pv.sh $IF
./windowsxp.sh $IF

cp /tmp/vms/vncsnapshot /usr/bin/
cd /tmp/rt

test_host -a -v debian,debian-pv,windowsxp -i $IF

